﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class AsynLoading : MonoBehaviour
{
    private static bool m_HasOpenLoadScene;
    private static bool m_WaitOpenLoadScene;
    private Slider slider;
    private void Awake()
    {
        m_HasOpenLoadScene = true;
        m_WaitOpenLoadScene = false;
        LoadingView.Instance.CloseLoadView();
    }
    private void Start()
    {
        slider = UnityTool.GetTheChildNodeComponetScript<Slider>(gameObject, "Slider");// transform.Find("LoadingObjPanel/Transfer/").GetComponent<Slider>();
    }
    private void Update()
    {
        slider.value = LoadingManager.Instance.LoadPrograss;
    }

    private void OnDestroy()
    {
        m_HasOpenLoadScene = false;
        m_WaitOpenLoadScene = false;
    }
    public static void LoadScene()
    {
        if (!m_HasOpenLoadScene && !m_WaitOpenLoadScene)
        {
            m_WaitOpenLoadScene = true;
            SceneManager.LoadScene("Loading");
        }
    }
}
